﻿using System.Net.NetworkInformation;

namespace com.fukefu
{
    public class MyPing
    {
        static Ping ping = new Ping();
        public static long GetRoundtripTime(string ip, int i)
        {
            long result = 0;
            for (int j = 0; j < i; j++)
            {
                result += (ping.Send(ip) != null) ? ping.Send(ip).RoundtripTime : (500 + i);
            }
            if (i != 0)
            {
                result = result / i;
            }
            return result;
        }
    }
}
